home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-portable.exe / quodlibet-3.3.0-portable / data / bin / genericpath.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  3KB  |  105 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. '''
  5. Path operations common to more than one OS
  6. Do not use directly.  The OS specific modules import the appropriate
  7. functions from this module themselves.
  8. '''
  9. import os
  10. import stat
  11. __all__ = [
  12.     'commonprefix',
  13.     'exists',
  14.     'getatime',
  15.     'getctime',
  16.     'getmtime',
  17.     'getsize',
  18.     'isdir',
  19.     'isfile']
  20.  
  21. def exists(path):
  22.     '''Test whether a path exists.  Returns False for broken symbolic links'''
  23.     
  24.     try:
  25.         os.stat(path)
  26.     except os.error:
  27.         return False
  28.  
  29.     return True
  30.  
  31.  
  32. def isfile(path):
  33.     '''Test whether a path is a regular file'''
  34.     
  35.     try:
  36.         st = os.stat(path)
  37.     except os.error:
  38.         return False
  39.  
  40.     return stat.S_ISREG(st.st_mode)
  41.  
  42.  
  43. def isdir(s):
  44.     '''Return true if the pathname refers to an existing directory.'''
  45.     
  46.     try:
  47.         st = os.stat(s)
  48.     except os.error:
  49.         return False
  50.  
  51.     return stat.S_ISDIR(st.st_mode)
  52.  
  53.  
  54. def getsize(filename):
  55.     '''Return the size of a file, reported by os.stat().'''
  56.     return os.stat(filename).st_size
  57.  
  58.  
  59. def getmtime(filename):
  60.     '''Return the last modification time of a file, reported by os.stat().'''
  61.     return os.stat(filename).st_mtime
  62.  
  63.  
  64. def getatime(filename):
  65.     '''Return the last access time of a file, reported by os.stat().'''
  66.     return os.stat(filename).st_atime
  67.  
  68.  
  69. def getctime(filename):
  70.     '''Return the metadata change time of a file, reported by os.stat().'''
  71.     return os.stat(filename).st_ctime
  72.  
  73.  
  74. def commonprefix(m):
  75.     '''Given a list of pathnames, returns the longest common leading component'''
  76.     if not m:
  77.         return ''
  78.     s1 = None(m)
  79.     s2 = max(m)
  80.     for i, c in enumerate(s1):
  81.         if c != s2[i]:
  82.             return s1[:i]
  83.     
  84.     return s1
  85.  
  86.  
  87. def _splitext(p, sep, altsep, extsep):
  88.     '''Split the extension from a pathname.
  89.  
  90.     Extension is everything from the last dot to the end, ignoring
  91.     leading dots.  Returns "(root, ext)"; ext may be empty.'''
  92.     sepIndex = p.rfind(sep)
  93.     if altsep:
  94.         altsepIndex = p.rfind(altsep)
  95.         sepIndex = max(sepIndex, altsepIndex)
  96.     dotIndex = p.rfind(extsep)
  97.     if dotIndex > sepIndex:
  98.         filenameIndex = sepIndex + 1
  99.         while filenameIndex < dotIndex:
  100.             if p[filenameIndex] != extsep:
  101.                 return (p[:dotIndex], p[dotIndex:])
  102.             None += 1
  103.     return (p, '')
  104.  
  105.